import request from '@/utils/request.js'

export function getarticles(params) {
  return request({
    url: '/v1_1/articles',
    params
  })
}

export function getchannel() {
  return request({
    url: '/v1_0/channels'
  })
}

/**
 * 获取文章
 */

export function getArticleById(articleId) {
  return request({
    url: `/v1_0/articles/${articleId}`
  })
}

export function followuser(target) {
  return request({
    url: '/v1_0/user/followings',
    method: 'POST',
    data: {
      target
    }
  })
}

export function deleteuser(target) {
  return request({
    url: '/v1_0/user/followings/' + target,
    method: 'DELETE'
  })
}

export function addcollect(target) {
  return request({
    method: 'POST',
    url: '/v1_0/article/collections',
    data: {
      target
    }
  })
}

export function deletecollect(target) {
  return request({
    url: '/v1_0/article/collections/' + target,
    method: 'DELETE'
  })
}

export function getcommentlist(params) {
  return request({
    method: 'GET',
    url: '/v1_0/comments',
    params
  })
}

export function postcomment(data) {
  return request({
    method: 'POST',
    url: '/v1_0/comments',
    data
  })
}
